package apiooday03;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionOperDemo {
    public static void main(String[] args) {
        Collection c1= new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add(".net");
        System.out.println();

        Collection c2= new ArrayList();
        c2.add("android");
        c2.add("ios");
        c2.add("java");

        c1.addAll(c2);
        System.out.println(c1);
        c2.add("s");
       // System.out.println(c1);
       // c2.clear();
        System.out.println(c1);
        System.out.println(c2.isEmpty());
        System.out.println(c2);
        //是否包含
        boolean contains =c2.containsAll(c1);
        System.out.println(contains);

        c1.retainAll(c2);//取交集，c1中保留c1和c2共有的元素
        System.out.println(c1);
        c1.remove("ios");
        System.out.println(c1);
        System.out.println(c2);
        c2.removeAll(c1);//删交集，c2中删除c1和c2共同的元素
        System.out.println(c1);
        System.out.println(c2);

    }
}
